package My.example;

import jdk.nashorn.internal.ir.RuntimeNode;
import sun.security.util.AuthResources_it;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Map;
@WebServlet(urlPatterns  ={"/demo3"})
public class serve2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Map<String,String[]>map=req.getParameterMap();
        for(String key:map.keySet()){
            System.out.printf(key+":");

            String[] values=map.get(key);
            for(String value:values){
                System.out.printf(value+" ");
            }
        }

    }
        @Override
        protected void doPost (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
            System.out.println("post");//编码中文问题
            req.setCharacterEncoding("UTF-8");
            String s=req.getParameter("username");
            System.out.println(s);
        }

}
